﻿@model ThaireInvestmentWeb.Models.ManageInstructionModel
@{
    ViewBag.Title = "ManageInstruction";
}
<script>
    $(document).ready(function () {

        applyValidateDate();
        $("#CreateDateForm,#CreateDateTO").datepicker(
      {
          dateFormat: 'dd/mm/yy',
          isBuddhist: true,
          showOn: 'button',
          showAnim: 'fadeIn',
          changeMonth: true,
          changeYear: true,
          showButtonPanel: true,
          buttonImage: '@Url.Content("~/Content/images/Calendar.png")',
          onSelect: function (dateText, inst)
          {
            

          }
      });

    });
</script>


<table class="navi" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td style="width: 100%;">
            <div class="navi">
                Instruction > Instruction
          
            </div>
        </td>
    </tr>
</table>
<table class="tableheader" width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td height="38" align="center" style="width: 100%; text-align: center;">Instruction List</td>
    </tr>
</table>

<p>
   @using (Html.BeginForm())
    {

        <table width="900" border="0" align="center">
            <tr>
                <td>   @Html.ValidationSummary(true) </td>
                </tr>
            <tr>
                <td>
                  
                        <table class="tableform" width="95%" border="0" align="center" cellspacing="2">
                            <tr>
                                <td width="200">
                                    <div align="right">Company: </div>
                                </td>
                                <td width="10">&nbsp;</td>
                                <td width="621">@Html.DropDownListFor(x => x.SelectCompanyID, Model.CompanyList)

                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div align="right">Financial Instrument  : </div>
                                </td>
                                <td>&nbsp;</td>
                                <td>@Html.DropDownListFor(x => x.SelectFinancialInstrument, Model.SelectFinancialInstrumentList)</td>
                            </tr>
                            <tr>
                                <td>
                                    <div align="right">Asset Class  : </div>
                                </td>
                                <td>&nbsp;</td>
                                <td>@Html.DropDownListFor(x => x.SelectAssetClass, Model.SelectAssetClassList)</td>
                            </tr>
                            <tr>
                                <td>
                                    <div align="right">Create Date From  : </div>
                                </td>
                                <td>&nbsp;</td>
                                <td>
                                    @Html.TextBoxFor(x => x.CreateDateForm, new {need_validateDate=true, @Value = string.Format("{0:dd/MM/yyyy}", Model.CreateDateForm) }) Ex.31/12/2014

                                    &nbsp;&nbsp;&nbsp;&nbsp;to&nbsp; 
                                     @Html.TextBoxFor(x => x.CreateDateTO, new {need_validateDate=true, @Value = string.Format("{0:dd/MM/yyyy}", Model.CreateDateTO) }) Ex.31/12/2014
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <div align="right">Ref No.</div>
                                </td>
                                <td>&nbsp;</td>
                                <td>@Html.TextBoxFor(x => x.RefNo)</td>
                            </tr>
                            <tr>
                                <td>
                                    <div align="right">Transaction  : </div>
                                </td>
                                <td>&nbsp;</td>
                                <td>
                                    @Html.DropDownListFor(x => x.SelectTransaction, Model.SelectTransactionList)

                                </td>
                            </tr>

                            <tr>
                                <td>
                                    <div align="right">Instruction Status  : </div>
                                </td>
                                <td>&nbsp;</td>
                                <td>@Html.DropDownListFor(x => x.SelectInstructionStatus, Model.SelectInstructionStatusList)</td>
                            </tr>

                            <tr>
                                <td>
                                    <div align="right"></div>
                                </td>
                                <td>&nbsp;</td>
                                <td>&nbsp;</td>
                            </tr>
                        </table>
                        <table width="95%" border="0" align="center">
                            <tr>
                                <td>
                                    <div align="center">

                                        <input type="submit" id="BtnSearch" name="BtnSearch" class="button" value=" Search ">
                                        &nbsp;&nbsp; 
                                     <input type="button" id="BtnAddNew" name="BtnAddNew" value=" Add new " class="button" onclick="self.location.href = 'InstructionForm';">
                                    </div>
                                </td>
                            </tr>
                        </table>
               
                       @if (Model.ManageInstructionDTOList != null && Model.ManageInstructionDTOList.Count > 0)
                    {
                        var grid = new WebGrid(source: Model.ManageInstructionDTOList, ajaxUpdateContainerId: "grid", rowsPerPage: 25);
                        @grid.GetHtml(htmlAttributes: new { id = "grid" }, tableStyle: "tablelist", headerStyle: "headertable", displayHeader: @Model.ManageInstructionDTOList.Count > 0,
            columns: grid.Columns(
             
                grid.Column(header: "NO.", format: item => (item.WebGrid.Rows.IndexOf(item) + 1) + (grid.PageIndex * grid.RowsPerPage), canSort: false),
                grid.Column(columnName: "RefNo", header: "Ref No.", canSort: false),
              
                grid.Column(columnName: "Company", header: "Company", canSort: false),
               
                grid.Column(columnName: "FinancialInstrumentName", header: "Financial Instrument", canSort: false),
                grid.Column(columnName: "AssetClass", header: "Asset Class", canSort: false),
                grid.Column( header: "Create Date", canSort: false,format: @<text> @ThaireInvestmentWeb.Util.WebUtil.FormatDate(item.CreateDate ) </text>),
                grid.Column(columnName: "Createby", header: "Create by", canSort: false),

                grid.Column(columnName: "Status", header: "Status", canSort: false),
                grid.Column(header: "Detail", format:
                    @<text>

                             <input type="image" onClick="go('@Url.Action("EditInstruction", "Instruction", new { headerID = item.InstructionHeaderID})    ');return false;"  src="@Url.Content("~/Content/images/b_edit.gif")"  title="แก้ไข">
                    </text>)));

                    }
                    
                      <a name="grid-anchor"></a>
                <script type="text/javascript">
                    $(function () {
                        $('th a, tfoot a').live('click', function () {
                            $(this).attr('href', '#grid-anchor');
                        });
                    });
                </script>     
                </td>
            </tr>
        </table>
    }
</p>
